
package ru.kpm.rectpack.represent;

import java.awt.Rectangle;
import java.util.List;
import javax.media.j3d.Group;

/**
 *
 * @author Podorov Alexander
 */

public class Pallet3DModel extends Model3D
{
    public Pallet3DModel(InputData inputData, OutputData outputData)
    {
        super(inputData, outputData);
    }

    protected Group createContent()
    {
        Group root = new Group();

        root.addChild(createAxises(X_AXIS, inputData.getPx() * SCALE, inputData.getPy() * SCALE, (inputData.getDpz() + inputData.getZ()) * SCALE));
        root.addChild(createAxises(Y_AXIS, inputData.getPx() * SCALE, inputData.getPy() * SCALE, (inputData.getDpz() + inputData.getZ()) * SCALE));
        root.addChild(createAxises(Z_AXIS, inputData.getPx() * SCALE, inputData.getPy() * SCALE, (inputData.getDpz() + inputData.getZ()) * SCALE));

        Rectangle pallet = outputData.getPallets().get(0);
        List<Rectangle> packs = outputData.getPacks().get(0);

        root.addChild(createPallet((float)pallet.getWidth() * SCALE, (float)pallet.getHeight() * SCALE, inputData.getDpz() * SCALE, 0.0f, 0.0f, 0.0f, wood.getTexture()));
        for (Rectangle rect : packs)
        {
            root.addChild(createBox((float)rect.getWidth() * SCALE, (float)rect.getHeight() * SCALE, inputData.getZ() * SCALE, (float)(rect.getMinX() * SCALE), (float)(rect.getMinY() * SCALE), inputData.getDpz() * SCALE, pack.getTexture()));
        }

        return root;
    }

    protected float[] getTransformation()
    {
        return new float[] {-0.73225236f, 0.6810038f, 0.0063465163f, 0.0f, -0.28380787f, -0.31361037f, 0.9061466f, 0.0f, 0.6190796f, 0.66172683f, 0.4229162f, -0.3f, 0.0f, 0.0f, 0.0f, 1.0f};
    }
}
